//传递并返回结构
#include<stdio.h>
#include<string.h>
#define NLEN 30
struct namect{
    char fname[NLEN];
    char lname[NLEN];
    int letters;
};
void  getinfo(struct namect *person);
//struct namect getinfo(void);
void makeinfo(struct namect[]);
//struct namect makeinfo(struct namect);
void showinfo(struct namect[]);
char * s_gets(char *st, int n);
int main(void)
{
    struct namect person[3];

    getinfo(person);
    //person = getinfo();
    makeinfo(person);
    //person = makeinfo(person);
    showinfo(person);

    return 0;
}

void  getinfo(struct namect *person)
{
    printf("Please enter your first name.\n");
    scanf("%s", person[0].fname);
    printf("Please enter your last name.\n");
    scanf("%s", person[0].lname);
}

// struct namect getinfo(void)
// {
//     struct namect temp;
//     printf("Please enter your first name.\n");
//     s_gets(temp.fname, NLEN);
//     printf("Please enter your last name.\n");
//     s_gets(temp.lname, NLEN);

//     return temp;
// }

//struct namect makeinfo(struct namect info)
void makeinfo(struct namect *person)
{
    person[0].letters = strlen(person[0].fname) + strlen(person[0].lname);

    //return info;
}

void showinfo(struct namect *info)
{
    printf("%s %s, your name contains %d letters.\n", info[0].fname, info[0].lname, info[0].letters);
}

char * s_gets(char *st, int n)
{
    char * ret_val;
    char * find;

    ret_val = fgets(st, n, stdin);
    if(ret_val)
    {
        find = strchr(st, '\n');
        if(find)
            *find = '\0';
        else
            while(getchar() != '\n')
                continue;
    }
    return ret_val;
}